package fonkin.com.wifisignapp.acticity.proceeding;

import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.squareup.picasso.Picasso;

import de.hdodenhof.circleimageview.CircleImageView;
import fonkin.com.wifisignapp.R;
import fonkin.com.wifisignapp.bean.user.User;
import fonkin.com.wifisignapp.constants.AppConstants;
import fonkin.com.wifisignapp.retrofit.BaseRetrofit;

import static com.squareup.picasso.MemoryPolicy.NO_CACHE;
import static com.squareup.picasso.MemoryPolicy.NO_STORE;

public class DeptUserDetail extends AppCompatActivity {

    TextView detail_name,detail_dept,detail_job,detail_location,detail_tel,detail_email;
    CircleImageView userHead;
    User user;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_dept_user_detail);
        user = (User) this.getIntent().getSerializableExtra("userDetail");
        detail_name = (TextView)findViewById(R.id.user_dept_name);
        detail_name.setText(user.getName());
        detail_dept = (TextView)findViewById(R.id.user_dept_infor);
        detail_dept.setText(user.getDeptName());
        detail_job = (TextView)findViewById(R.id.user_dept_job);
        detail_job.setText(user.getJobName());
        detail_location = (TextView)findViewById(R.id.user_dept_location);
        detail_location.setText(user.getBuildingName()+"--"+user.getRoomName());
        detail_tel = (TextView)findViewById(R.id.user_dept_tel);
        detail_tel.setText(user.getTel());
        detail_email = (TextView)findViewById(R.id.user_dept_email);
        detail_email.setText(user.getEmail());
        userHead = (CircleImageView)findViewById(R.id.user_dept_pic);
        Picasso
                .with(DeptUserDetail.this)
                .load(AppConstants.IMAGE_API+user.getHeadImg())
                .placeholder(R.drawable.loading_pic)
                .resize(80,50)
                .error(R.drawable.no_pic)
                .memoryPolicy(NO_CACHE, NO_STORE)
                .config(Bitmap.Config.RGB_565)
                .onlyScaleDown()
                .into(userHead);

    }

    public void CallPhone(View view){
        if (!"".equals(user.getTel())){
            Intent intent = new Intent(Intent.ACTION_DIAL);
            Uri data = Uri.parse("tel:" + user.getTel());
            intent.setData(data);
            startActivity(intent);
        }

    }
}
